﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BrainMatch
{
    public partial class NameBall : UserControl
    {
        private WaveManager m_Manager = null;
        private WaveDataSet.label_namesRow m_DataRow = null;
        public WaveDataSet.label_namesRow DataRow
        {
            get
            {
                return m_DataRow;
            }
        }
        public static List<NameBall> gBalls = new List<NameBall>();
        public static NameBall gSelectBall = null;
        public NameBall(WaveDataSet.label_namesRow dataRow,WaveManager manager)
        {
            m_Manager = manager;
            m_DataRow = dataRow;
            InitializeComponent();


            DataRow[] rows = m_Manager.Dataset.labels.Select(string.Format("name_id={0}", m_DataRow.id));

            label1.Text = string.Format("{0}({1})",m_DataRow.name,rows.Length);
            panel1.BackColor = BMUtility.StringToColor(m_DataRow.color);

            gBalls.Add(this);
        }

        private void OnSelect(object sender, EventArgs e)
        {
            foreach (NameBall ball in gBalls)
                ball.BackColor = Color.White;
            BackColor = Color.FromArgb(255, 255, 100);
            gSelectBall = this;
        }
    }
}
